package com.saifei.people.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.saifei.people.entity.SaifeiAdmin;
import com.saifei.people.entity.vo.LoginParamVo;
import com.saifei.people.mapper.SaifeiAdminMapper;
import com.saifei.people.service.SaifeiAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Genius小凡
 * @since 2021-02-17
 */
@Service
public class SaifeiAdminServiceImpl extends ServiceImpl<SaifeiAdminMapper, SaifeiAdmin> implements SaifeiAdminService {

    @Autowired
    SaifeiAdminMapper saifeiAdminMapper;

    @Override
    public String login(LoginParamVo vo) {
        SaifeiAdmin user = this.getOne(new QueryWrapper<SaifeiAdmin>().eq("username", vo.getUsername()).eq("password", vo.getPassword()));
        if(user != null)
            return user.getUsername();
        else return null;
    }

    @Override
    public SaifeiAdmin getInfo(String token) {
        SaifeiAdmin user = this.getOne(new QueryWrapper<SaifeiAdmin>().eq("username", token));
        if(user != null)
            return user;
        else return null;
    }
}
